import { getAction, deleteAction, putAction, postAction } from '@/api/manage'
import { serviceApi } from '@/api/common.js'

/**
 * 公共API接口
 */
export const api = {
  userProjList: (userId) => serviceApi.auth + `/users/${userId}/projects`,
  unRelateProjList: (tenantId, userId) => serviceApi.auth + `/tenants/${tenantId}/users/${userId}/projects/unassigned`,
  listDevicesByProjId: (projectId) => serviceApi.auth + `/assets/projects/${projectId}/devices`,
  delUserProject: (userId, id) => serviceApi.auth + `/users/${userId}/projects/${id}`
}

/**
 * 删除用户项目
 * @param {*} params
 * @returns
 */
export const delUserProject = (userId, id, params) => deleteAction(serviceApi.auth + `/users/${userId}/projects/${id}`, params);

/**
 * 添加用户项目
 * @param {*} params
 * @returns
 */
export const addUserProject = (userId, params) => postAction(serviceApi.auth + `/users/${userId}/projects`, params);

/**
 * 保存用户分配设备
 * @param {*} params
 * @returns
 */
export const saveUserDevice = (userId, params) => putAction(serviceApi.auth + `/users/${userId}/devices`, params);

/**
 *
 * @param {*} userId 用户ID
 * @param {*} params
 * { tenantId：'',//租户ID
 *   userId:'',//用户ID
 *   projectId:'',//项目ID
 *   deviceId:''//设备ID
 * }
 * @returns
 */
export const listUserDevice = (userId, params) => getAction(serviceApi.auth + `/users/${userId}/devices`, params);
